前言:
之前提到
我一直在想辦法讓原本的訓練模型
轉成IOS可以用的模型
但找了許多方法後
還是沒成功
所以我選擇用Firebase
來當作Python輸出輸入的中繼點
圖片下載程式碼:
import pyrebase
import os
import time
from firebase import firebase
#設定好 Firebase 後,可以從專案設定給予的資料,修改 config 內容
config = {
"apiKey": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"authDomain": "XXXXXXXXXXXXXXXXXX.firebaseio.com",
"databaseURL": "https://XXXXXXXXXXXXXXXXXX.firebaseio.com",
"projectId": "XXXXXXXX",
"storageBucket": "XXXXXXXX.appspot.com",
"messagingSenderId": "數字",
"appId": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}
firebase = pyrebase.initialize_app(config)
storage = firebase.storage()
my_image = "dog.jpg"
# Upload Image
# storage.child(my_image).put(my_image)
# Get url of image
auth = firebase.auth()
email = "XXXXXXX@gmail.com"
password = "XXXXXXXXXXXX"
user = auth.sign_in_with_email_and_password(email, password)
while True:
time.sleep(4)
url = storage.child(my_image).get_url(user['idToken'])
# Download Image
storage.child(my_image).download(filename="dog.jpg", path=os.path.basename(my_image))
print(url)